<template>
  <div style="width: 100%;height: 100%;">
    <div id="main5" style="width: 100%;height: 100%;"></div>
  </div>
</template>
<script>
const echarts = require('echarts')
export default {
  name: '',
  components: {
  },
  data () {
    return {
    }
  },
  created () {
  },
  mounted () {
    this.drawChart()
  },
  methods: {
    drawChart () {
      // 基于准备好的dom，初始化echarts实例
      const myChart = echarts.init(document.getElementById('main5'))
      // 指定图表的配置项和数据
      const data = [['2020-05-05', 116], ['2020-05-06', 129], ['2020-05-07', 135], ['2020-05-08', 86], ['2020-05-09', 73], ['2020-05-10', 85], ['2020-05-11', 73], ['2020-05-12', 68], ['2020-05-13', 92], ['2020-05-14', 130], ['2020-05-15', 245], ['2020-05-16', 139], ['2020-05-17', 115], ['2020-05-18', 111], ['2020-05-19', 309], ['2020-05-20', 206], ['2020-05-21', 137], ['2020-05-22', 128], ['2020-05-23', 85], ['2020-05-24', 94], ['2020-05-25', 71], ['2020-05-26', 106], ['2020-05-27', 84], ['2020-05-28', 93], ['2020-05-29', 85], ['2020-05-30', 73], ['2020-06-01', 83], ['2020-06-02', 125], ['2020-06-03', 107], ['2020-06-04', 82], ['2020-06-05', 44], ['2020-06-06', 72], ['2020-06-07', 106], ['2020-06-08', 107]]

      const dateList = data.map(function (item) {
        return item[0]
      })
      const valueList = data.map(function (item) {
        return item[1]
      })

      const option = {
        // Make gradient line here
        visualMap: [{
          show: false,
          type: 'continuous',
          seriesIndex: 0,
          min: 0,
          max: 400
        }],

        title: [{
          left: 'center',
          text: '系统使用率'
        }],
        tooltip: {
          trigger: 'axis'
        },
        xAxis: [{
          data: dateList
        }],
        yAxis: [{
          splitLine: { show: false }
        }],
        series: [{
          type: 'line',
          showSymbol: false,
          data: valueList
        }]
      }
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option)
      // 根据窗口的大小变动图表
      window.addEventListener('resize', () => {
        myChart.resize()
      })
    }
  }
}
</script>
<style lang="less" scoped>

</style>
